#include "atomic_op_asm.h"

ENTRY_NP(_atomic_swap_8)
	mov	x4, x0
1:	ldxrb	w0, [x4]
	stxrb	w3, w1, [x4]
	cbnz	w3, 1b
	dmb	st
	ret
END(_atomic_swap_8)

ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
STRONG_ALIAS(__sync_lock_test_and_set_1,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8)
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8)

ENTRY_NP(__sync_lock_release_1)
	stlrb	wzr, [x0]
	ret
END(__sync_lock_release_1)
